/* ==================================
	Main
 ================================== */
package it.unibo.is.domoticaContact;
import it.unibo.platform.expert.SubjectNameService;
import it.unibo.is.common.IS09Util;
import it.unibo.platform.lindaLike.LindaLike;

public  class DomoticaContact{

private UsrcmdContact usrcmd;
	
	public void doJob(){
		init();
		configure();
		start();
	}

	protected void init(){
   	//Properties used by the system  (TODO)
 	//System.setProperty("observeSpace", "unset");	//automatically set by selectInput
  
  	//Properties to show the internal behavior 
  		System.setProperty("coreTrace", "unset");
		System.setProperty("medclTrace", "unset");
		System.setProperty("obsTrace", "unset");
		System.setProperty("udpTrace", "unset");
		System.setProperty("tcpTrace", "unset");
		System.setProperty("httpTrace", "unset");
		initSupport();
	}

	protected void initSupport(){
		IS09Util.init();
		((LindaLike)LindaLike.getSpace()).clean();
		SubjectNameService.init();
	}
	protected void configure(){
	/* TODO
	* Define an application observer 
	* that auto-register itself in the shared space
	*/
// 	new ApplicationInputSpaceObserver( );	//once created, it observes the shared space

	

	SubjectNameService.addSubject( "TCP", "edController", "listEd", "192.168.0.101", 9020 );  
	SubjectNameService.addSubject( "TCP", "edController", "powerOn", "192.168.0.101", 9030 );  
	SubjectNameService.addSubject( "TCP", "edController", "powerOff", "192.168.0.101", 9040 );  
	SubjectNameService.addSubject( "TCP", "edController", "abortPowerOn", "192.168.0.101", 9060 );  
	SubjectNameService.addSubject( "TCP", "usrcmd", "listEdSuperflui", "192.168.0.101", 9050 );  

		usrcmd = new UsrcmdContact();
		usrcmd.setName("usrcmd");
 	}

	protected void start(){
		usrcmd.start();
 	}
	
// 	public static void main(String args[]) throws Exception {
//		DomoticaContact system = new DomoticaContact( );
//		system.doJob();
//	}
	
	public static void go() {
		DomoticaContact system = new DomoticaContact( );
		system.doJob();
	}
	
}//domoticaContact
